package com.example.javawebdemo.utils;

import org.mindrot.jbcrypt.BCrypt;

public class PasswordUtils {
    // 只保留核心方法
    public static String hashPassword(String plainPassword) {
        return BCrypt.hashpw(plainPassword, BCrypt.gensalt());
    }

    // 删除verifyPassword方法，统一使用标准验证
    public static boolean checkPassword(String plainPassword, String hashedPassword) {
        try {
            return BCrypt.checkpw(plainPassword, hashedPassword);
        } catch (Exception e) {
            return false; // 处理空字符串或非法哈希值
        }
    }
}

